﻿Imports System
Imports System.Collections.Generic
Imports System.Reflection
Imports System.Workflow.ComponentModel
Imports System.Xml

Namespace System.Workflow.ComponentModel.Serialization
    Friend NotInheritable Class StringCollectionMarkupSerializer
        Inherits WorkflowMarkupSerializer
        ' Methods
        Protected Friend Overrides Function CanSerializeToString(ByVal serializationManager As WorkflowMarkupSerializationManager, ByVal value As Object) As Boolean
            If (serializationManager Is Nothing) Then
                Throw New ArgumentNullException("serializationManager")
            End If
            If (value Is Nothing) Then
                Throw New ArgumentNullException("value")
            End If
            Return TypeOf value Is ICollection([Of] String)
        End Function

        Protected Friend Overrides Function DeserializeFromString(ByVal serializationManager As WorkflowMarkupSerializationManager, ByVal propertyType As Type, ByVal value As String) As Object
            If (serializationManager Is Nothing) Then
                Throw New ArgumentNullException("serializationManager")
            End If
            If (propertyType Is Nothing) Then
                Throw New ArgumentNullException("propertyType")
            End If
            If (value Is Nothing) Then
                Throw New ArgumentNullException("value")
            End If
            If MyBase.IsValidCompactAttributeFormat(value) Then
                Return MyBase.DeserializeFromCompactFormat(serializationManager, [TryCast](serializationManager.WorkflowMarkupStack.Item(GetType(XmlReader)),XmlReader), value)
            End If
            Return SynchronizationHandlesTypeConverter.UnStringify(value)
        End Function

        Protected Friend Overrides Function GetProperties(ByVal manager As WorkflowMarkupSerializationManager, ByVal obj As Object) As PropertyInfo()
            Return New PropertyInfo(0  - 1) {}
        End Function

        Protected Friend Overrides Function SerializeToString(ByVal serializationManager As WorkflowMarkupSerializationManager, ByVal value As Object) As String
            If (serializationManager Is Nothing) Then
                Throw New ArgumentNullException("serializationManager")
            End If
            If (value Is Nothing) Then
                Throw New ArgumentNullException("value")
            End If
            Return SynchronizationHandlesTypeConverter.Stringify([TryCast](value,ICollection([Of] String)))
        End Function

    End Class
End Namespace

